package pojo;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;

@Entity(name="jpa_user")
public class User {
	@Id
	private Integer id;
	private String cname;
	private int age;
	//对象一对多
	@ElementCollection(fetch=FetchType.LAZY)
	@JoinTable(name="addrs",joinColumns={@JoinColumn(name="c_id")})
	@Column(name="c_addrs")
	private Set<Address> addrs = new HashSet<Address>();
	
	/**
	 * 基本类型的一对多
	 */
	@ElementCollection(fetch=FetchType.LAZY)
	@JoinTable(name="tels",joinColumns={@JoinColumn(name="c_id")})
	@Column(name="tel_num")
	private Set<String> tels = new HashSet<String>();
	
	public Set<String> getTels() {
		return tels;
	}
	public void setTels(Set<String> tels) {
		this.tels = tels;
	}
	
	public Set<Address> getAddrs() {
		return addrs;
	}
	public void setAddrs(Set<Address> addrs) {
		this.addrs = addrs;
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getCname() {
		return cname;
	}
	public void setCname(String cname) {
		this.cname = cname;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}

	
	
}
